<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<title>角色管理</title>
<script>
	$(function(){
		/*列表初始化*/
		var gridParam = {
			"columns" : [ [ 
			                { field : "roleName", width : 200, title : "角色名称" }
			                ,{ field : "moduleDataRight", width : 130, title : "业务数据权限",formatter: function(value,row,index){
			                	if(value=='self') return '仅自己数据可见';
			                	if(value=='department') return '所属项目部数据可见';
			                	if(value=='all') return '所有数据可见';
			                 }}
			                ,{ field : "roleDesc", width : 400, title : "角色描述" }
			] ],
			singleSelect : true,
			onSelect:function(index, row){
				var $btn = $("a[motion_code=03],a[motion_code=02],a[motion_code=08]");
				if(row.roleName=='超级管理员'){
					$btn.linkbutton('disable'); return ;
				}else{
					$btn.linkbutton('enable'); return ;
				}
			}
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam, gridParam));

		/*事件响应*/
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var id = $(this).attr("motion_code");
			var flag = $(this).hasClass("l-btn-disabled");
			if(flag) return ;
			switch (id) {
				case "01":
					p.gridAdd({ title : "角色新增", width : 400, height : 330 });
					break;
				case "02":
					p.gridModify({title : "角色编辑" ,width : 400, height : 330 });
					break;
				case "03":
					p.gridDelete();
					break;
				case "04":
					p.gridView({title : "角色查看", width : 400, height : 330 });				
					break;
				case "05":
					p.gridQuery();
					break;
				case "08":
					var row = p.getSelection();
					if(row){
						var _p = {
							title : row.roleName+ "---角色授权", width : 850, height : 400, href : p.gridConfigUrl || '',data : row , maximized:true,
							buttons : [ p.buttons.submit, p.buttons.close ]
						};
						p.dialog = $("<div/>").dialog("openWin", _p);
					}
					break;
				default:
					break;
			}
		});
	});
</script>
</head>
<body  class="easyui-layout">
		<!-- 但行高度33px，多行时 33乘以行数  -->
		<div id="querybar" data-options="region:'north',split:false,border:false" style="height:33px;">
			<div class="easyui-panel" data-options="fit:true,border:false">
				<!-- 查询条件表单，根据配置进行替换  -->
				<form id="queryForm" >
				 <input type="hidden" name="className" value="com.fs.base.pojo.Role" />
				 <div style="margin-top:5px;margin-left:10px;float:left;">
				  	<input class="easyui-textbox" name="roleName" style="width:240px;" data-options="label:'角色名称:',required:false" />
					<input type="hidden" name="roleName_searchType" value="like" />
				 </div>
				</form>
			</div>
		</div>  
	
		<!-- 工具栏按钮 -->
		<div id="toolbar" class="easyui-panel" style="padding:3px;">
		<!-- 
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="01">新增</a>
	      	<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="02">编辑</a>
	     	<a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true" id="03">删除</a>
	     	<a href="#" class="easyui-linkbutton" iconCls="icon-rosette" plain="true" id="06">授权</a>
	     	<a href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true" id="04">查看</a>
	      	<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" id="05">查询</a>
			 -->
		</div>
		
		<!-- 表格 -->
		<div region="center" border="false">
			<table id="dataGrid"></table>
		</div>
</body>
</html>